package com.pinda.controller;


import com.pinda.base.entity.PdTransportLineType;

import com.pinda.commonutils.Page;
import com.pinda.commonutils.Result;

import com.pinda.commonutils.StatusCode;
import com.pinda.feign.AggregationFeign;
import com.pinda.service.IPdTransportLineTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 线路类型表 前端控制器
 * </p>
 *
 * @author lc
 * @since 2023-06-14
 */
@RestController
@RequestMapping("/pd_transport_line_type")
public class PdTransportLineTypeController {

    @Autowired
    IPdTransportLineTypeService iPdTransportLineTypeService;



    @Autowired
    AggregationFeign aggregationFeign;



    /**
     * 查询机构
     * @param
     * @return
     */
    @PostMapping("/queryPdOrg")
    public Result queryPdOrg(){
        List list = this.aggregationFeign.queryPdOrg();
        if(!list.isEmpty()){
            return new Result<>(true, StatusCode.OK,"ok",list);
        }
        return new Result<>(true, StatusCode.ERROR,"error",list);
    }





    /**
     * 分页查询线路类型
     * @param page
     * @return
     */
    @PostMapping("/queryPageTransportLineType")
    public Result queryPageTransportLineType(@RequestBody Page<PdTransportLineType> page){
        return this.iPdTransportLineTypeService.queryPageTransportLineType(page);
    }


    /**
     * 根据id修改线路类型
     * @param transportLineType
     * @return
     */
    @PostMapping("/updataTransportLineType")
    public boolean  updataTransportLineType(@RequestBody PdTransportLineType transportLineType){
        return this.iPdTransportLineTypeService.updateById(transportLineType);
    }





    /**
     * 添加线路类型
     * @param transportLineType
     * @return
     */
    @PostMapping("/addTransportLineType")
    public boolean  addTransportLineType(@RequestBody PdTransportLineType transportLineType){
        return this.iPdTransportLineTypeService.save(transportLineType);
    }



    @GetMapping("/deleteTransportLineType")
    public Boolean deleteTransportLineType(Integer id) {

        return this.iPdTransportLineTypeService.removeById(id);
    }

    @GetMapping("/queryAllTransportLineType")
    public List<PdTransportLineType> queryAllTransportLineType() {
        List<PdTransportLineType> list = this.iPdTransportLineTypeService.list();
        return list;
    }


}
